/**
 * 
 */
package cn.springsoter.core.security.helper;

import java.lang.reflect.Field;
import java.util.Objects;

import cn.springsoter.core.security.annotation.SensitiveInfo;

/**
 * 加解密帮助类
 * 
 * @author kevin
 *
 */
public class CryptoHelper {

	/**
	 * 判断SensitiveInfo这个类的needCrypto是否为true，false的不做加/解密处理
	 * 
	 * @param object
	 * @return	true-需要加/解密，false-不需要加/解密
	 */
	public static boolean needCrypto(Field field) {
		if(Objects.isNull(field)) {
			return false;
		}
		SensitiveInfo sensitiveField = field.getAnnotation(SensitiveInfo.class);
		if(Objects.nonNull(sensitiveField)) {
			return sensitiveField.needCrypto();
		}
		return false;
    }
}
